package com.example.qxfw.nyqx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.qxfw.common.entity.ny.BadCondition;
import com.example.qxfw.nyqx.mapper.BadConditionMapper;
import com.example.qxfw.nyqx.service.BadConditionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BadConditionServiceImpl implements BadConditionService{

    @Autowired
    private BadConditionMapper badConditionMapper;

    @Override
    public List<BadCondition> getList(String indexId, String climateCondition, String contrastType1, String contrastType2, String climateConditionType, String climateConditionValue) {
        if(climateConditionType.equals("<"))
        {
            return badConditionMapper.selectList(Wrappers.<BadCondition>lambdaQuery().eq(BadCondition::getIndexid,Integer.parseInt(indexId))
                    .eq(BadCondition::getClimatecondition,climateCondition)
                    .in(BadCondition::getContrasttype,Integer.parseInt(contrastType1),Integer.parseInt(contrastType2))
                    .le(BadCondition::getClimateconditionvalue,Double.parseDouble(climateConditionValue)));
        } else{
            return badConditionMapper.selectList(Wrappers.<BadCondition>lambdaQuery().eq(BadCondition::getIndexid,Integer.parseInt(indexId))
                    .eq(BadCondition::getClimatecondition,climateCondition)
                    .in(BadCondition::getContrasttype,Integer.parseInt(contrastType1),Integer.parseInt(contrastType2))
                    .ge(BadCondition::getClimateconditionvalue,Double.parseDouble(climateConditionValue)));
        }
    }
}
